/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
$(function(){
     $_Search = $("#address");
    $_SearchDic = $("#SearchDic");
    var _left = $_Search.offset().left - 1;
    var _top = $_Search.offset().top + $_Search.height();
    $_SearchDic.css({"left": _left, "top": _top});

    $_SearchDic.find('li').live("mouseover", function () {
        $(this).addClass("hover");
    });
    $_SearchDic.find('li').live("mouseleave ", function () {
        $(this).removeClass("hover");
    });
    $_SearchDic.find('li').live("click", function () {
        $_Search.val($(this).children('a').text());
        $_Search.attr("dic", $(this).attr("id"));
        $_SearchDic.hide();
    });
    $_Search.keyup(function () {
        if ($(this).val() == "") {
            $_SearchDic.hide();
            return false;
        };
        Search(HouseType,$_Search.val());
    });
    $(".jjr_quyu ul li").each(function (i) {
        $(this).mouseover(function () {
            $(this).siblings().removeClass("quyu").add("quyu");
            $("[class^='user_qu_v']").hide().eq(i).show();
        });
    });
  
    var Search=function(_Type,_Keyword){
  $.ajax({
   type: "GET",
   dataType:"html",
   url: "/tools/ajax.php",
   data: "action=SearchHouse&type="+_Type+"&Keyword="+_Keyword,
   success: function(msg){
     if(msg!=""){    

          $_SearchDic.html(msg);
          $_SearchDic.slideDown();
     }else{
          $_SearchDic.html('');
         $_SearchDic.hide();
     }
     
   }
  });
}
});

